<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 解构语法
    // 数组解构
    let arr = [1, 2];
    let [, b] = arr;
    console.log(b);
    // 对象解构
    let user = { name: "xaiohui", age: 13 };
    let { age } = user;
    console.log(age);

    // 将变量转化为对象
    let subject = "chinese";
    let score = 87;
    // 变量的名字就会变成属性的名字，变量的值就会变成属性的值
    let opt = { subject, score };
    console.log(opt);
  </script>
</html>
